<%inherit file="/unmenued_base.mako"/>
<%namespace file="/breadcrumbs.mako" import="make_breadcrumbs"/>

<%def name="render_race_tag(race)">
%if race == 't':
	<span class='race_tag terran'>[T]</span>
%elif race == 'z':
	<span class='race_tag zerg'>[Z]</span>
%elif race == 'p':
	<span class='race_tag protoss'>[P]</span>
%else:
	<span class='race_tag'>[?]</span>
%endif
</%def>

<%def name="render_player(player)">
% if player:
	${player.name} ${self.render_race_tag(player.race)}	
% else:
	Unknown [?]
% endif
</%def>

<%def name="render_start_location(start_location)">
<%
	locations = ['','Top-Right','Top-Right','Right','Bottom-Right','Bottom-Right','Bottom',
		'Bottom-Left', 'Bottom-Left', 'Left', 'Top-Left', 'Top-Left', 'Top']
%>
<span class="start_location">${start_location} (${locations[start_location]})</span>
</%def>

<%def name="content()">

<h2>${c.league.name} </h2>
${make_breadcrumbs(c.breadcrumbs)}

<div id="game_info">
	<h3>Set ${c.game_number}</h3>
	<div id="player_info">

		<ul id="player_one_info">
			<li>Name : ${self.render_player(c.game.player_one)}</li>
			% if c.game.player_one_start_location:
			<li>Start: ${render_start_location(c.game.player_one_start_location)}</li>
			% endif
		</ul>
		<ul id="player_two_info">
			<li>Name : ${self.render_player(c.game.player_two)}</li>
			% if c.game.player_two_start_location:
			<li>Start: ${render_start_location(c.game.player_two_start_location)}</li>
			% endif
		</ul>
	</div>

	% if c.game.game_map:
		<h4>Map: ${c.game.game_map.full_name}</h4>
		<img class="map_image" src="/media/images/maps/${c.game.game_map.id}.jpg" alt="Map for ${c.game.game_map.name}">
	% else:
		<h4>Map: Unknown</h4>
	% endif
</div>

<div id="commentary_area">
	% if len(c.game.commentary_sets) == 0:
		<p>There are no known videos for this game.</p>
	% else:
		<div id="commentary_view">
			<div id="commentary">
			</div>
			<p><a href='#' class="return_to_author_selection">Return to Commentary List</a></p>
		</div>

		<div id="commentary_selection">
			<p>Choose your commentary:</p>
			<ul>
				% for commentary_set in c.game.commentary_sets.values():
					<li><a href="#" class="author_selection">${commentary_set.author}</a></li>
				% endfor
			</ul>
		</div>
	% endif
</div>


<div id="set_navigation">
	<p>
	% if c.game_number > 1:
		<a href="/${h.make_set_url(c.league.name_key, c.stage_path,
				c.match.team_one.name_key, c.match.team_two.name_key, c.game_number - 1)}">Previous Set</a>
	% else:
		Previous Set
	% endif
	% if c.game_number < c.total_games:
		<a href="/${h.make_set_url(c.league.name_key, c.stage_path,
				c.match.team_one.name_key, c.match.team_two.name_key, c.game_number + 1)}">Next Set</a>
	% else:
		Next Set
	% endif
	</p>
</div>

</%def>

<%def name="head()">
<script type='text/javascript' src="/media/js/swfobject-2.2.js"></script>
<script type='text/javascript' src='/media/js/commentary_objects.js'></script>
<script type='text/javascript'>
	$(function() {
		$(".author_selection").click(function() {
			var author = $(this).text();
			$("#commentary").load('/commentary/${c.game.id}/' + author);
			$('#commentary_selection').hide()
			$('#commentary_view').show()
			return false;
		})
		$(".return_to_author_selection").click(function() {
			shutdownPlayers()
			$('#commentary_view').hide()
			$('#commentary_selection').show()
			$('#commentary').empty()
			return false;
		})
	})
</script>
</%def>
